<template>
	<view class="content">
		添加页面
		<table>
			<tr>
				<td>产品名称</td>
				<td><input type="text" style="background-color: antiquewhite;" v-model="Name"></td>
			</tr>

			<td>产品价格</td>
			<td><input type="text" style="background-color: antiquewhite;" v-model="Prince"></td>
			</tr>
			<tr>
				<td>产品状态</td>
				<td><input type="text" style="background-color: antiquewhite;" v-model="Status"></td>
			</tr>
		</table>
		<view style="display: flex;">
		<button type="submit" @click="clss()">返回</button>
		<button type="submit" @click="add()">保存</button>
		</view>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				Name: "",
				Prince: "",
				Status: "",
			}
		},
		methods: {
			clss(){
				uni.navigateTo({
					url:"/pages/index/index"
				})
			},
			add() {
				uni.request({
					url: 'http://127.0.0.1:8080/add', //仅为示例，并非真实接口地址。
					data: {
						name: this.Name,
						price: this.Prince,
						status: this.Status,
					},
					method: "POST",
					header: {
						'content-type': 'application/x-www-form-urlencoded' //自定义请求头信息
					},
					success: (res) => {
						console.log(res.data)
						if (res.data.Cre == 200) {
							alert("添加成功")
							uni.navigateTo({
								url: "/pages/index/index"
							})
						} else {
							alert("添加失败")
						}
					}
				});
			},
		}
	}
</script>

<style>
	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}

	.logo {
		height: 200rpx;
		width: 200rpx;
		margin-top: 200rpx;
		margin-left: auto;
		margin-right: auto;
		margin-bottom: 50rpx;
	}

	.text-area {
		display: flex;
		justify-content: center;
	}

	.title {
		font-size: 36rpx;
		color: #8f8f94;
	}
</style>